var windowName = "myContactSelect";
var Page;
apiready = function(){
    onWindowShow(function () {
        console.log(windowName + " show")

        setContact(getLocData("myContact"))
        getData()
    })
    onWindowHide(function () {
        console.log(windowName + " hide")
    })
    console.log("index page is OK");
    Page = createVM("#Page",{
        defContact:{}
        ,list:[]
    },{
        //页面方法
        "init":function () {
        }
        ,setContact:function (contact) {
            setLocData('curContact',contact)
            goback();
        }
    })
    Page.init()
}

function getData() {
    apiGet("/api/userContacts", {}, function (res, code) {
        if (code == 200) {
            setContact(res.data)
            // showToast(res.message);
        }else {

        }
        logJson(res,"/app/my/Contact_: ");
    });
}

function setContact(data) {
    if (isTrue(data)) {
        setLocData('myContact',data)
        //设置默认数据
        var defContact = data[0];
        Page.defContact = defContact;
        var list = arrayDelIndex(data,0);
        //设置其他数据
        if(isTrue(list)){
            Page.list = list
        }else {
            Page.list = []
        }
    }
}